import {createStore} from 'vuex'
import SystemConstants from "@/utils/SystemConstants";

export default createStore({
    state: {
        allEnum: {},
        space: {},
        userInfo: SystemConstants.defUser,
        loginDialogFlag: false,
        loginPageFlag: false,
        avatarImgUrl: localStorage.getItem("avatarImgUrl")
    },
    getters: {
        getAllEnum(state) {
            return state.allEnum
        },
        getSpace(state) {
            return state.space
        },
        getUserInfo(state) {
            return state.userInfo
        },
        getLoginDialogFlag(state) {
            return state.loginDialogFlag
        },
        getLoginPageFlag(state) {
            return state.loginPageFlag
        },
        getAvatarImgUrl(state) {
            return state.avatarImgUrl
        }
    },
    mutations: {
        setAllEnum(state, data) {
            state.allEnum = data
        },
        setSpace(state, data) {
            state.space = data
        },
        setUserInfo(state, data) {
            state.userInfo = data
        },
        setLoginDialogFlag(state, data) {
            state.loginDialogFlag = data
        },
        setLoginPageFlag(state, data) {
            state.loginPageFlag = data
        },
        setAvatarImgUrl(state, data) {
            state.avatarImgUrl = data
        }
    },
    actions: {
        setAllEnum(state, val) {
            state.commit('setAllEnum', val)
        },
        setSpace(state, val) {
            state.commit('setSpace', val)
        },
        setUserInfo(state, val) {
            state.commit('setUserInfo', val)
        },
        setLoginDialogFlag(state, val) {
            state.commit('setLoginDialogFlag', val)
        },
        setLoginPageFlag(state, val) {
            state.commit('setLoginPageFlag', val)
        },
        setAvatarImgUrl(state, val) {
            state.commit('setAvatarImgUrl', val)
        }
    },
    modules: {}
})